import { http } from "@/utils/http";

export type commonResult<T> = {
    code: number;
    msg: string;
    result: T;
};

/** 5.1 获取统计数据选择 */
export const getStatistics = (params?: object) => {
    return http.request<commonResult<any>>("get", '/topo/topo/v2/echarts', {
        params
    });
};

/** 5.2 表格数据选择 */
export const getTable = (params?: object) => {
    return http.request<commonResult<any>>("get", '/topo/topo/v2/tables', {
        params
    });
};

/** 5.3 获取分组 */
export const getGroup = (params?: object) => {
    return http.request<commonResult<any>>("get", '/topo/topo/v2/group', {
        params
    })
}

/** 5.4 添加文件夹 */
export const addFolder = (data?: object) => {
    return http.request<commonResult<any>>("post", '/topo/topo/v2/group', {
        data
    });
};

/** 5.5 添加素材 */
export const addMaterial = (data?: object) => {
    return http.request<commonResult<any>>("post", '/topo/topo/v2/graph', {
        data
    });
};

/** 5.6 上传图片 */
export const uploadImage = (data?: object) => {
    return http.request<commonResult<any>>("post", '/topo/topo/v2/upload', {
        data
    });
};

/** 5.7 编辑文件夹 */
export const editFolder = (data?: object) => {
    return http.request<commonResult<any>>("put", '/topo/topo/v2/group', {
        data
    });
};

/** 5.8 删除文件夹 */
export const deleteFolder = (data?: object) => {
    return http.request<commonResult<any>>("delete", '/topo/topo/v2/group', {
        data
    });
};

/** 5.9 编辑图库名称 */
export const editGraph = (data?: object) => {
    return http.request<commonResult<any>>("put", '/topo/topo/v2/graph', {
        data
    });
};

/** 5.10 删除图库 */
export const deleteGraph = (data?: object) => {
    return http.request<commonResult<any>>("delete", '/topo/topo/v2/graph', {
        data
    });
};

/** 5.11 获取建筑 */
export const getBuilding = (params?: object) => {
    return http.request<commonResult<any>>("get", '/topo/topo/v2/buildings', {
        params
    });
};

/** 5.12 获取建筑图纸 */
export const getBuildingGraph = (params?: object) => {
    return http.request<commonResult<any>>("get", '/topo/topo/v2/drawings', {
        params
    });
};

/** 5.13 获取设备 */
export const getDevice = (params?: object) => {
    return http.request<commonResult<any>>("get", '/topo/topo/v2/devices', {
        params
    });
};

/** 5.14 获取产品类型数据 */
export const getProductType = (params?: object) => {
    return http.request<commonResult<any>>("get", '/topo/topo/v2/product-field', {
        params
    });
};

/** 5.15 获取监控 */
export const getMonitor = (params?: object) => {
    return http.request<commonResult<any>>("get", '/topo/topo/v2/moniters', {
        params
    });
};
/** 5.16 获取组态数据 */
export const getTopo = (params?: object) => {
    return http.request<commonResult<any>>("get", '/topo/topo/v2/topo-info', {
        params
    });
};
/** 5.17 保存组态数据 */
export const saveTopoData = (data?: object) => {
    return http.request<commonResult<any>>("put", '/topo/topo/v2/topo/topo-data', {
        data
    })
}
/** 5.18 获取视频地址 */
export const getVideo = (params?: object) => {
    return http.request<commonResult<any>>("get", '/topo/topo/v2/moniter-url', {
        params
    });
};
/** 5.19 获取分组下的图库 */
export const getTopoPic = (params?: object) => {
    return http.request<commonResult<any>>("get", '/topo/topo/v2/graphs', {
        params
    });
};
/** 5.20 设备控制 */
export const deviceControl = (data?: object) => {
    return http.request<commonResult<any>>("post", '/topo/topo/v2/device-control', {
        data
    });
};
/** 5.1.1 获取模板分组 */
export const getTemplateGroup = (params?: object) => {
    return http.request<commonResult<any>>("get", '/topo/topo/v2/topo/group', {
        params
    });
};
/** 5.1.2 添加模板文件夹 */
export const addTemplateFolder = (data?: object) => {
    return http.request<commonResult<any>>("post", '/topo/topo/v2/topo/group', {
        data
    });
};
/** 5.1.3 编辑模板文件夹 */
export const editTemplateFolder = (data?: object) => {
    return http.request<commonResult<any>>("put", '/topo/topo/v2/topo/group', {
        data
    });
};
/** 5.1.4 删除模板文件夹 */
export const deleteTemplateFolder = (data?: object) => {
    return http.request<commonResult<any>>("delete", '/topo/topo/v2/topo/group', {
        data
    });
};
/** 5.1.5 获取分组下的模板 */
export const getTemplate = (params?: object) => {
    return http.request<commonResult<any>>("get", '/topo/topo/v2/topo/tpls', {
        params
    });
};
/** 5.1.6 添加组态模板 */
export const addTemplate = (data?: object) => {
    return http.request<commonResult<any>>("post", '/topo/topo/v2/topo/tpl', {
        data
    });
};
/** 5.1.7 删除组态模板 */
export const deleteTemplate = (data?: object) => {
    return http.request<commonResult<any>>("delete", '/topo/topo/v2/topo/tpl', {
        data
    });
};
/** 5.1.8 编辑组态模板 */
export const editTemplate = (data?: object) => {
    return http.request<commonResult<any>>("put", ' /topo/topo/v2/topo/tpl', {
        data
    });
};

/** 5.23 保存组态模板数据 */
export const saveTemplateData = (data?: object) => {
    return http.request<commonResult<any>>("put", '/topo/topo/v2/topo/tpl-topo-data', {
        data
    });
};

/** 1.12.1 获取组态模板详情 */
export const getTemplateDetail = (params?: object) => {
    return http.request<commonResult<any>>("get", '/system/topo/v2/topo/tpl', {
        params
    });
};
/** 5.24 控制命令配置读取 */
export const commandconfig = (params?: object) => {
    return http.request<commonResult<any>>("get", '/topo/topo/v2/device/command-config', {
        params
    });
};